package org.hitchhike.web.front.controller;

import java.util.List;

import org.hitchhike.core.domain.Cities;
import org.hitchhike.core.domain.Provinces;
import org.hitchhike.core.service.CitiesService;
import org.hitchhike.core.service.ProvincesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/front")
public class FrontRestController {

  @Autowired
  private ProvincesService provincesService;
  @Autowired
  private CitiesService citiesService;

  @RequestMapping(value = "/provinces", method = RequestMethod.GET)
  public List<Provinces> findProvinces() {
    return provincesService.findAll();
  }

  @RequestMapping(value = "/cities/{provinceid}", method = RequestMethod.GET)
  public List<Cities> findCities(@PathVariable String provinceid) {
    return citiesService.findByProvinceId(provinceid);
  }
}
